<template>
  <div id="growup">
    <div class="navbanner lunbo" >
      <router-link to="/introduction">
        <img src="../../static/images/banner1.png" class=""/>
      </router-link>
    </div>
    <div class="navbanner clearfix" style="margin-top: 0;">
      <div class="nav fl">
          <h2><i class="el-icon-trophy" style="margin-right: 5px;"></i>成长记录</h2>        
      </div>   
      <div class="content fl">
         <div class="timebox">
        <ul id="list" >
          <li  v-for="(temp,index) in storyList"  :key="index">
            <div  style="float:left">
              <img v-if="temp.imgsrc" :src="preUrl+temp.imgsrc" width="120px" style="float:left" />
              <div>{{ temp.childId }}</div>
            </div>
            <div>
                <a
                href="javascript:void(0);"
                @click="toDetail(temp)" 
                :title="temp.title"
              >{{temp.title}}</a>
            </div>
          </li>
        </ul>
      </div>
      </div>           
    </div>
  </div>
</template>

<script>
import request from "../utils/request";
import Sticky from '@/components/Sticky'
export default {
  data () {
    
    return {
      name:'growup',
      currentPage: 1,
      pageSize: 15,
      newBlogData: [],
      isEnd: false,
       //成长记录类
      storyList: [],
      url: {
        storyList: "/sunGrowup/list",
      },
      preUrl: "http://localhost:8080/jeecg-boot/sys/common/static/",
    }
  },
   components: {
    // 注册组件
  
    Sticky
  },
  mounted () {
    // 注册scroll事件并监听
    var that = this
    var loading = false
  },
  created () {
    this.getStoryList();
  },
  methods: {
     //跳转成长记录详情页面
    toDetail(data) {
      this.$router.push("./subjectInfo?id=" + data.id);
    },
    //获取成长记录
    getStoryList() {
      request
        .get(this.url.storyList, {
          params: {
            pageSize:6,
            // category: 6,
          },
        })
        .then((res) => {
          if (res.data.success) {
              let item = res.data.result.records
              // for (let i = 0; i < item.length; i++) {
              //   item[i].imgSrc = this.preUrl+item[i].imgSrc
              // }
            this.storyList =item;
            console.log(this.storyList);
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    formatDate: function (time) {
      var date = new Date(time)
      var year = date.getFullYear()
      /* 在日期格式中，月份是从0开始的，因此要加0
       * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
       * */
      var month =
        date.getMonth() + 1 < 10
          ? '0' + (date.getMonth() + 1)
          : date.getMonth() + 1
      var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
      // 拼接
      return year + '-' + month + '-' + day
    }
  }
}
</script>

<style>
#growup .navbanner .content{
  background: #f6f6f6;
}

</style>
